package com.jason.www.state_pattern.demo2.state;


import com.jason.www.state_pattern.demo2.context.ATMContext;

public class ATMNoCashState implements IATMState {

    private ATMContext atmContext;

    public ATMNoCashState(ATMContext atmContext) {
        this.atmContext = atmContext;
    }

    @Override
    public void insertCard() {
        System.out.println("插卡成功");
    }

    @Override
    public void submitPwd() {
        if("123".equals(atmContext.getPassword())){
            System.out.println("密码正确");
        }else{
            System.out.println("密码错误");
        }
    }

    @Override
    public void getCash() {
        System.out.println("提现失败！ATM没有足够的现金！");
        //弹出卡片
        ejectCard();
    }

    @Override
    public void queryBalance() {
        System.out.println("本账号余额为：" + atmContext.getBalance());
    }

    @Override
    public void ejectCard() {
        System.out.println("银行卡取回成功，请及时取走");
    }
}
